package com.zsh.fmmall.controller;

import com.zsh.fmmall.service.CategoryService;
import com.zsh.fmmall.service.IndexImgService;
import com.zsh.fmmall.service.ProductService;
import com.zsh.fmmall.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin//前端请求的跨域访问
@RequestMapping("/index")
@Api(value = "提供⾸⻚数据显示所需的接⼝",tags = "首页管理")
public class IndexController {
    @Autowired
    private IndexImgService indexImgService;
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ProductService productService;

    @ApiOperation("⾸⻚轮播图接⼝")
    @GetMapping("/indexImgs")
    public ResultVO listIndexImgs(){
//        System.out.println("imgs");
        return indexImgService.listIndexImgs();
    }
    @ApiOperation("商品分类查询接⼝——连接查询操作")
    @GetMapping("/categoryList")
    public ResultVO listCatetory(){
        return categoryService.listCategories();
    }
    @ApiOperation("商品分类查询接⼝——子查询操作")
    @GetMapping("/categoryList2")
    public ResultVO listCatetory2(){
        return categoryService.listCategories2();
    }

    @GetMapping("/list-recommends")
    @ApiOperation("查询推荐商品接⼝")
    public ResultVO listRecommendProducts() {
        return productService.listRecommendProducts();
    }
//首页-分类商品推荐
    @GetMapping("/category-recommends")
    @ApiOperation("首页商品分类推荐接⼝")
    public ResultVO listFirstLevelCategories(){
        return categoryService.listFirstLevelCategories();
    }

}
